﻿
Public Class FormMain
    Dim objUser As New clsUser
    Dim objProdInfo As New clsProdInfo
    Private Sub FormMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        connectDB()
        getUserListByCJ()
        setDgvData()
    End Sub

    Private Sub connectDB()
        g_szInitFileName = My.Application.Info.DirectoryPath & "\pq.ini"
        g_jsInitFileName = My.Application.Info.DirectoryPath & "\js.ini"
        g_Server.szDrive = GetIniFile("SERVER", "DRIVE", "PostgreSQL ANSI", g_szInitFileName)
        g_Server.szIPadr = GetIniFile("SERVER", "IP", "", g_szInitFileName)
        g_Server.szDbn = GetIniFile("SERVER", "DBN", "ZHENANSF", g_szInitFileName)
        g_Server.szUid = GetIniFile("SERVER", "UID", "sa", g_szInitFileName)
        g_Server.szPas = GetIniFile("SERVER", "PAS", "sa", g_szInitFileName)
        g_Server.iOver = CInt(GetIniFile("SERVER", "OVER", "-1", g_szInitFileName))

        If False = g_fDBconnect And 0 = g_iDBconnResult Then
            If "" = g_Server.szIPadr Or "0.0.0.0" = g_Server.szIPadr Then
            Else
                g_fDBconnect = True

                'データベース接続
                With g_Server
                    g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDbn, .szUid, .szPas, .iOver)
                    If 1 <> g_iDBconnResult Then
                        .szDrive = CStr(IIf("PostgreSQL" = .szDrive, "PostgreSQL ANSI", "PostgreSQL"))
                        g_iDBconnResult = DBacs.Connect(.szDrive, .szIPadr, .szDbn, .szUid, .szPas, .iOver)
                    End If
                End With
            End If
        End If

    End Sub

    Private Sub getUserListByCJ()
        Dim dtUser As DataTable = objUser.getUserListByCJ(5, "1")
        cmbOpers.Properties.Items.Clear()
        For index = 0 To dtUser.Rows.Count - 1
            cmbOpers.Properties.Items.Add(dtUser.Rows(index)("user_name"))
        Next
        If dtUser.Rows.Count > 0 Then
            cmbOpers.Properties.Items(0).CheckState = CheckState.Checked
        End If
        cmbOpers.Properties.DropDownRows = cmbOpers.Properties.Items.Count + 1
        cmbOpers.Properties.ShowButtons = False
        cmbOpers.Properties.ShowPopupCloseButton = False
    End Sub

    Public Sub setDgvData()
        Dim dt13 As DataTable = objProdInfo.getProdInfoByStatus("13", "1")
        dgvJieShou.AutoGenerateColumns = False
        dgvJieShou.DataSource = dt13
        lblCountJS.Text = dgvJieShou.Rows.Count
        Dim dt14 As DataTable = objProdInfo.getProdInfoByStatus("14")
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dt14
        lblCountPQ.Text = dgv.Rows.Count
        Dim n_count As Object = dt14.Compute("count(prod_id)", " pq_dt <= '" & Now.ToShortDateString() & " 23:59:59.999' and pq_dt >= '" & Now.ToShortDateString() & " 00:00:00.000'")
        If n_count IsNot DBNull.Value Then
            lblCountPQtoday.Text = n_count.ToString()
        Else
            lblCountPQtoday.Text = "0"
        End If
    End Sub

    Private Sub btnRefresh_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click
        setDgvData()
    End Sub

    Private Sub btnMesPgd_Click(sender As Object, e As EventArgs) Handles btnMesPgd.Click
        Dim formMesPgd As New FormMesPgd()
        formMesPgd.usr = cmbOpers.Text.Trim()
        formMesPgd.ShowDialog(Me)
    End Sub

    Private Sub btnMesWorkReportList_Click(sender As Object, e As EventArgs) Handles btnMesWorkReportList.Click
        Dim formMesWorkReportList As New FormMesWorkReportList()
        formMesWorkReportList.ShowDialog(Me)
    End Sub

    Private Sub btnControlPoint_Click(sender As Object, e As EventArgs) Handles btnControlPoint.Click
        Dim formControlPoint As New FormControlPoint()
        formControlPoint.usr = cmbOpers.EditValue.ToString()
        formControlPoint.ShowDialog(Me)
    End Sub

    Private Sub btnControlPointRecord_Click(sender As Object, e As EventArgs) Handles btnControlPointRecord.Click
        Dim formControlPointRecord As New FormControlPointRecord()
        formControlPointRecord.ShowDialog(Me)
    End Sub

    Private Sub btnStandingBook_Click(sender As Object, e As EventArgs) Handles btnStandingBook.Click
        Dim formStandingBook As New FormStandingBook()
        formStandingBook.usr = cmbOpers.EditValue.ToString()
        formStandingBook.ShowDialog(Me)
    End Sub

    Private Sub btnStandingBookRecord_Click(sender As Object, e As EventArgs) Handles btnStandingBookRecord.Click
        Dim formStandingBookRecord As New FormStandingBookRecord()
        formStandingBookRecord.ShowDialog(Me)
    End Sub

    Private Sub btnWorkReport_Click(sender As Object, e As EventArgs) Handles btnWorkReport.Click
        Dim frm As New FormWorkReport()
        frm.usr = cmbOpers.Text.Trim()
        frm.ShowDialog(Me)
    End Sub

    Private Sub btnWorkReportList_Click(sender As Object, e As EventArgs) Handles btnWorkReportList.Click
        Dim frm As New FormWorkReportList()
        frm.ShowDialog(Me)
    End Sub

    Private Sub btnReceive_Click(sender As Object, e As EventArgs) Handles btnReceive.Click
        Dim frm As New FormReceive()
        frm.usr = cmbOpers.Text.Trim()
        frm.ShowDialog(Me)
    End Sub

    Private Sub btnReceiveList_Click(sender As Object, e As EventArgs) Handles btnReceiveList.Click
        Dim frm As New FormReceiveList()
        frm.ShowDialog(Me)
    End Sub

    Private Sub FormMain_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        DBacs.Disconnect()
    End Sub

End Class

Public Class entityPgdMes
    Public pgd_code As String
    Public oper_date As String
    Public mes_project_code As String
    Public mes_project_name As String
    Public support_model As String
    Public type_value As String
    Public oper_count As String
    Public lhj As String
    Public lhj_type As String
    Public note As String
    Public workshop_id As Integer
    Public validity As String
    Public status As String
    Public origin As String
    Public Ope As String
    Public start_time As String
    Public end_time As String
    Public jp_type As String
    Public jp_spec As String

End Class


